<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="theme-color" content="#FFFFFF" />
		<title>预录入列表</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../ui/common/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../../ui/common/css/common.css" />
		<link rel="stylesheet" type="text/css" href="../../ui/home/css/index.css" />
		<link rel="stylesheet" type="text/css" href="../../ui/common/css/icons-extra.css" />
	</head>
	<body>
		<style>
			.quick-mark-container {background: rgba(0,0,0,0.1);height: 100%; width: 100%; position: fixed; top: 0; left: 0;}
			#scan-screen {width: 100%; height: 100%;}
			.quick-mark-container .action {position: absolute; bottom: 0; width: 100%; background: rgba(0,0,0,0.5); color: #FFFFFF;}
			.quick-mark-container .action .active { color: blue;}
		</style>
    <div class="quick-mark-container">
        <div id="scan-screen"></div>
    	<div class="action" style="">
    		<div class="camera mui-col-xs-6 active mui-pull-left mui-text-center p-10" href="javascript:void(0);">
    			<em class="mui-icon-extra mui-icon-extra-sweep"></em><br>
    			扫码
    		</div>
    		<div class="local mui-col-xs-6 mui-pull-left mui-text-center p-10" href="javascript:void(0);">
    			<em class="mui-icon mui-icon-image"></em><br>
    			相册
    		</div>
    	</div>
    </div>
    		<script src="../../ui/common/js/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../ui/common/js/jquery-1.10.2.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../ui/common/js/common.js" type="text/javascript" charset="utf-8"></script>

    <script>
    mui.init({
        swipeBack:true //启用右滑关闭功能
    });
    var scan = null;
    var isOpen = false; // 闪光灯是否开始标志 true:闪光灯已经开启 false:闪光灯关闭
    // 条码识别成功事件
    function onmarked( type, result ) {
        var text = '未知: ';
        switch(type){
            case plus.barcode.QR:
            text = 'QR: '; // 二维码
            break;
            case plus.barcode.EAN13:
            text = 'EAN13: ';
            break;
            case plus.barcode.EAN8:
            text = 'EAN8: ';
            break;
        }
        alert( text+result );
    }
    // 创建扫描控件
    function startRecognize() {
        scan = new plus.barcode.Barcode('bcid');
        scan.onmarked = onmarked; 
    }
    // 开始扫描
    document.getElementById("startScan").addEventListener('tap',function(){
        startRecognize();
        scan.start();
    })
    // 取消扫描
    document.getElementById("cancelScan").addEventListener('tap',function(){
        startRecognize();
        scan.cancel();
    })
    //  开启和关闭闪光灯
    document.getElementById("setFlash").addEventListener('tap',function(){
        startRecognize();
        isOpen = !isOpen;
        if(isOpen){
            scan.setFlash(true);
        }else{
            scan.setFlash(false);
        }
    })
</script>
	</body>
</html>
